<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="title">
                Hiệu quả quảng bá
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <p:panel style="width: 500px">
                        <h:panelGrid columns="2">
                            Ngày 
                            <p:calendar value="#{broadcastEffectivenessBean.startDate}" pattern="dd/MM/yyyy" timeZone="Asia/Saigon" navigator="true"
                                        required="true" requiredMessage="Bạn chưa chọn ngày"/>
                            <p:commandButton value="Xem" action="#{broadcastEffectivenessBean.find()}" oncomplete="processingDialog.hide()"
                                             onclick="processingDialog.show()" update="table"/>
                        </h:panelGrid>
                    </p:panel>
                </h:form>
                <br/>
                <h:form id="table">
                    <p:dataTable value="#{broadcastEffectivenessBean.list}" var="item" style="width: 600px" rendered="#{broadcastEffectivenessBean.list != null and broadcastEffectivenessBean.list.size() > 0}"
                                 rows="1" paginator="#{broadcastEffectivenessBean.list.size() > 1}" resizableColumns="true">

                        <p:column headerText="Nội dung SMS" sortBy="#{item.sms}">
                            <b>Tổng số tin shoot:</b> #{item.broadcastStatistic.shootingCount} <br/>
                            <b>Tổng số tin nhắn lại:</b> #{item.msisdns.size()} ( #{(item.msisdns.size() / item.broadcastStatistic.shootingCount) * 100}%) <br/>
                            <b>Bắt đầu shoot:</b> #{item.broadcastStatistic.startShootingTime} <br/>
                            <b>Kết thúc shoot:</b> #{item.broadcastStatistic.endShootingTime} <br/>
                            <b>Nội dung:</b> #{item.sms}
                        </p:column>
                        <p:column headerText="Danh sách khách có nhắn tin lại">

                            <ui:repeat value="#{item.msisdns}" var="mdn">
                                #{mdn} <br/>
                            </ui:repeat>
                        </p:column>
                    </p:dataTable>

                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
